/*
 * Mathy.cpp
 *
 *  Created on: 18.03.2014
 *      Author: Nicolas Winkler
 */

#include <iostream>
#include <string>

#include "Tokenizer.h"
#include "Parser.h"
#include "Exception.h"
#include "Expression.h"
#include "SpecialCommandInterpreter.h"

using namespace std;

int main(int argc, const char * argv[])
{
	std::cout << "Ready!\n";
	while (true) {
		string input = "";
		std::getline(cin, input);
		if (input.size() > 0 && input[0] == '\\') {
			solver::SpecialCommandInterpreter::interpret(input);
		} else {
			try {
				solver::Tokenizer tokenizer(input);
				tokenizer.run();

				solver::Parser parser(tokenizer);
				parser.run();
			} catch (solver::Exception& e) {
				cout << e.getErrMessage() << "\n";
			} catch (...) {
				cout << "internal error\n";
			}
		}
	}

	cout << "Bye!\n";

	return 0;
}

